package com.qf.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ApiListingBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import static javafx.beans.binding.Bindings.select;

@Configuration//指定当前类是配置类
@EnableOpenApi//swagger注解
public class SwaggerConfig {
    @Value("${swagger.enabled}")
    private boolean enabled;
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.OAS_30).enable(enabled)
                .apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.basePackage("com.qf.md.unit.controller"))
                .paths(PathSelectors.any()).build();
    }
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("api接口文档")
                .description("具体包含了xxx模块")
                .contact(new Contact("zhangqinghua","http://www.baidu.com","qf@qq.com"))
                .version("1.0")
                .build();
    }

}
